Slack
Refer the following steps to create a slack based contact point in Grafana.
- Create a slack app and an incoming webhook following these instructions.
- Navigate to
Contact pointstab in theAlertingsection of the Grafana instance. - Click on
Add contact point, give a name to the contact point and selectSlackfrom theIntegrationdrop down. - Add the webhook created from the first step under the
Webhook URLoption. - Add the following snippet under the
Titleoption in theOptional Slack settingssection:
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ if .CommonLabels.cluster }}[{{ .CommonLabels.cluster }}]{{ end }} {{ .CommonLabels.alertname }}
- Add the following snippet under the
Text Bodyoption in theOptional Slack settingssection:
{{ with index .Alerts 0 -}}
:chart_with_upwards_trend: *<{{ .GeneratorURL }}|Graph>*
{{- if .Annotations.runbook }} :notebook: *<{{ .Annotations.runbook }}|Runbook>*{{ end }}
{{ end }}
*Alert details:*
{{ range .Alerts -}}
{{ if .Labels.severity }}>*Severity:* `{{ .Labels.severity }}`{{ end }}
>*Description:* {{ .Annotations.description }}
{{ if .Annotations.printDetails }}>
>*Details:*
{{ range .Labels.SortedPairs }}>• *{{ .Name }}:* `{{ .Value }}`
{{ end }}
{{ end }}
{{ end }}
info
While this standard alert template should be sufficient for most use-cases, you can also customize the alert template using the Grafana documentation.